package com.zgm.ch05.aop.around._3_5_5;

import org.springframework.aop.framework.ProxyFactory;

public class ProfilingExample {

	public static void main(String[] args) {
		WorkerBean bean = getWorkerBean();
//		bean.doSomeWork(10000000);
		System.out.println(bean.doSomeWork(1));
		System.out.println(bean.doOtherWork(2));
	}
	
	private static WorkerBean getWorkerBean() {
		WorkerBean target = new WorkerBean();
		ProxyFactory factory = new ProxyFactory();
		
		factory.setTarget(target);
		factory.addAdvice(new ProfilingInterceptor());
		
		return (WorkerBean) factory.getProxy();
		
	}
}
